
class Admin::SurveyFeesController < Admin::BaseController

  before_action :find_fee, only: [:edit, :update]

  def index
    @survey_fees = SurveyFee.paginate(page: params[:page] || 1, per_page: params[:per_page] || 15).order("id desc")
  end

  def new
    @survey_fee = SurveyFee.new
  end

  def create
    @survey_fee = SurveyFee.new(params.require(:survey_fee).permit!)

    if @survey_fee.save
      flash[:notice] = "创建成功"
      redirect_to admin_survey_fees_path
    else
      render action: :new
    end

  end

  def edit
    render action: :new
  end

  def update
    @survey_fee.attributes = params.require(:survey_fee).permit!
    if @survey_fee.save
      flash[:notice] = "修改成功"
      redirect_to admin_survey_fees_path
    else
      render action: :new
    end
  end

  private

  def find_fee
    @survey_fee = SurveyFee.find(params[:id])
  end

end
